package Componente;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

public class ExtraerWord 
{
	private InputStream entrada = null;
	public ExtraerWord(String ruta) 
	{
		File dir = new File(ruta);
		try 
		{
			FileInputStream fis = new FileInputStream(dir);
            entrada = fis;
		} 
		catch (FileNotFoundException e) 
		{
			e.printStackTrace();
		}
	}
	
	public String leerDoc()
	{
		XWPFDocument ardocx = null;
		try {
			ardocx = new XWPFDocument(entrada);
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
		@SuppressWarnings("resource")
		XWPFWordExtractor xwpfWordExtractor = new XWPFWordExtractor(ardocx);
		return (xwpfWordExtractor.getText());
		
	}

}